<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
	<%@ page import="com.sun.jersey.api.client.config.ClientConfig" %>
    <%@ page import="com.sun.jersey.api.client.config.DefaultClientConfig" %> 
    <%@ page import="com.sun.jersey.api.client.*" %> 
    <%@ page import="javax.ws.rs.core.UriBuilder" %>
    <%@ page import="java.net.URI" %>
    <%@ page import="javax.ws.rs.core.UriBuilder" %>
    <%@ page import="java.util.*" %>
    <%@ page import="cs9322.assign3.model.*" %>
    <%@ page import="javax.ws.rs.core.MediaType" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<% 
String id = request.getParameter("id");
ClientConfig clientConfig = new DefaultClientConfig();
Client client = Client.create(clientConfig);
WebResource service = client.resource("http://localhost:8080/cs9322.assign3.coffee");
ClientResponse cr = service.path("starbucks").path("payments/"+ id).accept(MediaType.TEXT_XML).get(ClientResponse.class);
Payment payment = cr.getEntity(Payment.class);
%>

<table>
<tr>
	<td>Order id:</td>
	<td><%=payment.getOrderId() %></td>
</tr>
<tr>
	<td>Payment type:</td>
	<td><%=payment.getPaymentType() %></td>
</tr>
<tr>
	<td>Payment amount:</td>
	<td><%=payment.getPaymentAmount() %></td>
</tr>
<tr>
	<td>Payment detail:</td>
	<td><%=payment.getPaymentDetail()%></td>
</tr>
</table>
<br>
<br>
	<a href="index.jsp">Home Page</a>
<br>
<br>

	<table>
	<tr>
	<td>
	response status:
	</td>
	<td>
	<%=cr.getStatus() %>
	</td>
	</tr>
	<tr>
	<td>
	response headers:
	</td>
	<td>
	<%=cr.getHeaders() %>
	</td>
	</tr>
	<tr>
	<td>
	response data:
	</td>
	<td>
	<%=cr.getResponseDate() %>
	</td>
	</tr>
	<tr>
	<td>
	options:
	</td>
	<td>
	<%=cr.getAllow() %>
	</td>
	</tr>
	</table>
</body>
</html>